feat: Adding a preserve mtime feature to copy_to_directory and copy_directory #898
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds the
preserve_mtime
attribute to thecopy_to_directory
andcopy_directory
rules. When set the copied files will have their modified time set to the same value as the original source.The motivation for adding this feature is that I was building a third party library from source using
rules_foreign_cc
and tried to usecopy_to_directory
to merge in a configuration header with the upstream source. Without this feature all of the modify times were reset and this caused the build to erroneously determine that generated files packaged with the source were out of date. With thispreserve_mtime
feature I was successfully able to build the third party library using the released version of these files.Changes are visible to end-users: yes
The
copy_directory
andcopy_to_directory
rules now support preserving the original modification time of their sources.Test plan
test_preserve_mtime
undere2e/smoke
test was added that verifies that the modified times are the same in the destination as the source.preserve_mtime = True
attribute was temporally removed from the targets that are used by the test. It was verified the old behavior still occurred and the test failed with an appropriate error message.e2e
were executed.